import 'package:flutter/material.dart';

class HomeList extends StatelessWidget {
  HomeList({super.key, required this.notifyList});
  List notifyList;
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 10, bottom: 10),

      child: Column(
        children: [
          Row(
            children: [
              Image.asset('images/notice@2x.png', width: 20),
              Text('社区'),
              Text('公告', style: TextStyle(color: Colors.orange)),
            ],
          ),
          ListView(
            shrinkWrap: true,
            physics: NeverScrollableScrollPhysics(), //禁止用户手动滑动,避免滑动冲突
            children:
                notifyList.map((item) {
                  return GestureDetector(
                    //识别用户手势的核心组件
                    onTap: () {
                      // 单击
                      Navigator.pushNamed(
                        context,
                        '/detail',
                        arguments: {'id': item['id']},
                      );
                    },
                    child: Container(
                      child: Container(
                        padding: EdgeInsets.all(10),
                        margin: EdgeInsets.only(top: 10),
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(10),
                          color: Colors.white,
                        ),
                        // ),
                        child: Column(
                          children: [
                            Row(
                              children: [
                                Expanded(
                                  child: Text(
                                    item['title'],
                                    style: TextStyle(
                                      fontSize: 16,
                                      fontWeight: FontWeight.bold,
                                    ),
                                    maxLines: 2,
                                    overflow: TextOverflow.ellipsis,
                                  ),
                                ),
                              ],
                            ),
                            const SizedBox(height: 8),
                            Row(
                              children: [
                                Expanded(
                                  child: Text(
                                    item['content'],
                                    style: TextStyle(fontSize: 14),
                                    maxLines: 3,
                                    overflow: TextOverflow.ellipsis,
                                  ),
                                ),
                              ],
                            ),
                            const SizedBox(height: 8),
                            Row(
                              children: [
                                Expanded(
                                  child: Text(
                                    item['createdAt'],
                                    style: TextStyle(
                                      fontSize: 12,
                                      color: Colors.grey,
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ],
                        ),
                      ),
                    ),
                  );
                }).toList(),
          ),
        ],
      ),
    );
  }
}
